#include "TimeMeasure.h"

int32_t getMilliCount()
{
	// Something like GetTickCount but portable
	// It rolls over every ~ 12.1 days (0x100000/24/60/60)
	// Use GetMilliSpan to correct for rollover
	timeb tb;
	ftime(&tb);
	int32_t nCount = tb.millitm + (tb.time & 0xfffff) * 1000;
	return nCount;
}

int32_t getMilliSpan(int32_t nTimeStart)
{
	int32_t nSpan = getMilliCount() - nTimeStart;
	if (nSpan < 0)
		nSpan += 0x100000 * 1000;
	return nSpan;
}
